package com.itheima_02;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
//获取注解中的方法
public class RefTest {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException {
        //获取字节码对象
        Class clazz = Class.forName("com.itheima_02.MethodTest");
        //创建对象
        MethodTest mt = (MethodTest) clazz.newInstance();
        //获取方法
        Method[] methods = clazz.getMethods();
        //遍历方法
        for (Method method : methods) {
            if (method.isAnnotationPresent(Test.class)){
                method.invoke(mt);
            }
        }
    }
}
